import java.util.Arrays;

public class Test1 {
    public static void main(String[] args) {//判断数组中是否有3个连续的奇数
        int[] array = {1, 1, 2, 3, 1};
        boolean ret = func3(array);
        System.out.println(ret);
    }

    public static boolean func3(int[] array) {
        int count = 0;
        for (int i = 0; i < array.length; i++) {
            if (array[i] % 2 != 0) {
                count++;
                if (count == 3) {//立即判断
                    return true;
                }
            } else {
                count = 0;
            }
        }
        return false;
    }





    public static void main2(String[] args) {//找出数组中的多数元素
        int[] array = {1, 1, 5, 3, 1};
        int ret = func2(array);
        System.out.println(ret);
    }

    public static int func2(int[] array) {
        Arrays.sort(array);
        return array[array.length / 2];
    }





    public static void main1(String[] args) {//找出数组中只出现了一次的数字
        int[] array = {1, 3, 5, 3, 1};
        int ret = func1(array);
        System.out.println(ret);
    }

    public static int func1(int[] array) {
        int ret = 0;
        for (int i = 0; i < array.length; i++) {
            ret ^= array[i];
        }
        return ret;
    }
}
